var myapp = angular.module("myapp", []);
myapp.controller('loginCtrl', ['$scope', '$http',
    function ($scope, $http) {
        $scope.username = "admin";
        $scope.password = "admin";
        $scope.doLogin = function () {
            $scope.errMess = "";
            $scope.params = {
                "username": $scope.username,
                "password": $scope.password
            };
            $http({
                method: 'post',
                url: '/login',
                params: $scope.params
            }).then(function successCallback(response) {
                if (response.data.status == "OK") {
                    window.location.href = "home.html";
                } else {
                    $scope.errMess = response.data.message;
                    $scope.changeImg();
                }
            }, function errorCallback(response) {

            });
        };
        $scope.changeImg = function () {
            angular.element("#verifycode").attr("src", "scf/security/getCheckCode?time=" + new Date().getTime());
        };

    }]);
